
import { ConfigFileName, TConfigFileName } from "./Config";
import { LanguageDefineConfig } from "./LanguageDefineConfig";
import "./CCImport"
import { sys } from "cc";
import { HTML5, OPPO, VIVO } from "cc/env";

type TPlatformType = keyof typeof apeng.EPlatformType

/**平台 */
let platformType: TPlatformType = "web"

// 自动判断平台
if (platformType as any == "web") {
    if (!HTML5) {
        if (window["wx"])
            platformType = "wx"
        if (window["qq"])
            platformType = "qq"
        if (window["tt"])
            platformType = "tt"
    }
    if (OPPO)
        platformType = "oppo"
    if (VIVO)
        platformType = "vivo"

    if (sys.isNative)
        platformType = "taptap"
}

/**默认语言 */
const defaultType: keyof typeof apeng.ELanguageType = "chinese"

const chinaLanguage = (defaultType as any) == "chinese"

/**内部自定义常量逻辑 */
export const CGameData = {
    SettingUrl: "setting/prefab/SettingUI",
    PropGetUrl: "scene/prefab/ui/PropGetUI",
    FailUrl: "scene/prefab/ui/FailUI",
    LevelSelectUrl: "scene/prefab/ui/LevelSelectUI",
    SuccessUrl: "scene/prefab/ui/SuccessUI",
    RunUIUrl: "scene/prefab/ui/RunUI",
    ResetCardAnimUI: "scene/prefab/ui/ResetCardAnimUI"
}

let gameName: string = "麻将凑十挪对对"
gameName = "麻将挪对对"
if (platformType == "vivo")
    gameName = "麻将凑十"

export const isCouShi = gameName == "麻将凑十挪对对"

export const initData: apeng.IInitData = {
    gameName,
    rewardVideoUseShare: false,
    isTest: true,
    isLog: true,
    platformType,
    isWaitScene: false,
    server: {
        gameId: "",
        requestIp: "",
    },
    configPlatform: "platform",
    useModuleStorageType: false,
    openWebSimulationUI: true,
    useWebSimulationUI: false,
    openPrivacy: (<TPlatformType[]>[
        // "web",
        "qq",
        "vivo",
        "oppo",
        "taptap",
    ]).indexOf(platformType) !== -1 && chinaLanguage,
    showLoadingText: (<TPlatformType[]>[
        "web",
        "wx",
        "tt",
        "oppo",
        "vivo",
        "ks",
        "xiaomi",
        "hbs",
        "qq",
    ]).indexOf(platformType) !== -1 && chinaLanguage,
    versionId: gameName == "麻将挪对对" ? "" : "2023SA0027142",
    openGm: false,
    loadingCompleteColorAnim: "#EEF2FE",
    initSceneUrl: "scene/scene/Scene",
    audioClickUrl: "main/audio/click_sound",
    configUrl: "config/configs",
    touchMovePrefabUrl: "main/particle/7/prefab",
    touchClickPrefabUrl: "main/particle/1/prefab",
    sceneChangeWaitUrl: "",
    uiUrl: {
        index: "main/prefab/index/Index" + (chinaLanguage ? "" : "2") + "UI",
        indexBg: "main/prefab/index/IndexBgUI",
        prop: "main/prefab/prop/PropUI",
        sidebar: "ttSidebar/prefab/TTSidebarUI",
    },
    startBlockAd: 0,
    share: {
        callTime: 0,
        list: {
            title: [
                "一口气玩了20关，根本停不下来。",
                "@你，这是一款超难消除游戏",
                "超还上头的消除游戏，来冲吧",
                "不通关谁都别睡觉！",
            ],
            imgUrl: [],
        },
        templateId: [],
    },
    newUseEnterGame: (<TPlatformType[]>[
        "web",
        "qq",
        "taptap",
    ]).indexOf(platformType) === -1,
    loadingDuration: 0,
    configDefine: ConfigFileName,
    languageDefine: LanguageDefineConfig,
    getLanguageType: () => {
        let value = sys.localStorage.getItem("language")
        if (value === null || value === "null" || value === undefined || value === "")
            return defaultType
        let type = Number(value)
        if (isNaN(type))
            return defaultType
        return defaultType
    },
}
